#ifndef _UFO_FRAMEWORK_ANIMATION_H_
#define _UFO_FRAMEWORK_ANIMATION_H_

#include "handle.h"
#include "view.h"

DECLARE_HANDLE(UFO_Animation);

typedef enum _UFO_Animation_Type
{
    Animation_rect = 1,
    Animation_alpha = 2,
	Animation_angle = 4,
    Animation_axisZ = 8,
	Animation_colorMask = 16,
}UFO_Animation_Type;

typedef enum _UFO_Animation_TimingFunction
{
    TimingFunctionDefault,
    TimingFunctionLinear,
    TimingFunctionEaseIn,
    TimingFunctionEaseOut,
    TimingFunctionEaseInEaseOut,//### like mac's cocoa
    
    TimingFunctionQuinticEaseOut,//### tween add
    TimingFunctionCubicEaseOut,
    TimingFunctionQuadraticEaseOut,
    TimingFunctionExponentialEaseOut,
    
}UFO_Animation_TimingFunction;

typedef struct _UFO_Animation_Value
{
	UFO_Animation_Type type;
    float alpha;
	float redMask, greenMask, blueMask;
    ufoRect rect;
    float angle;
    float z;
}UFO_Animation_Value;

typedef enum UFO_ANIMATION_STATE
{
	UFO_ANIMATION_PLAYING = 1,
	UFO_ANIMATION_FINISH = 2,
}UFO_ANIMATION_STATE;

typedef int (*ANIMATIONPROC)(UFO_Animation animation, UFO_ANIMATION_STATE state, void* userdata);

float internal_calcInterpolation(UFO_Animation_TimingFunction timingFunc, float s, float e,
	float duration, float t);

UFO_Animation ufoAnimationCreate(UFO_View view);

int ufoAnimationDelete(UFO_Animation animation);

int ufoAnimationPlay(UFO_Animation animation);

int ufoAnimationStop(UFO_Animation animation);

int ufoAnimationSetDuration(UFO_Animation animation, int duration);

int ufoAnimationSetDelay(UFO_Animation animation, int delay);

int ufoAnimationSetToValue(UFO_Animation animation, UFO_Animation_Value value);

int ufoAnimationSetRepeatTime(UFO_Animation animation, int repeatTime);

int ufoAnimationSetAutoreverses(UFO_Animation animation, int reverses);

int ufoAnimationSetTimingFunction(UFO_Animation animation, UFO_Animation_TimingFunction timingFunction);

int ufoAnimationGetState(UFO_Animation animation);

int ufoAnimationSetCallback(UFO_Animation animation, ANIMATIONPROC proc, void* userdata);

#endif